//
//  TagViewController.m
//  JiuLe
//
//  Created by 黄鑫 on 16/9/1.
//  Copyright © 2016年 Fine. All rights reserved.
//

#import "TagViewController.h"

@interface TagViewController ()
@property (weak, nonatomic) IBOutlet UITextField *textFieldTag;
@property (weak, nonatomic) IBOutlet UIButton *btnUp;
@property (weak, nonatomic) IBOutlet UIButton *btnDrinkwater;
@property (weak, nonatomic) IBOutlet UIButton *btnMovement;
@property (weak, nonatomic) IBOutlet UIButton *btnSleep;

@end

@implementation TagViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"标签";
    [self showNavgationWithLeftItemWithTitle:@"返回"];
    [self showNavgationWithLeftTiele:@"" andleftBtnAction:nil WithRightTiele:@"保存" andrigheBtnAction:@selector(sureAction)];
    [_btnUp addTarget:self action:@selector(tapAction:) forControlEvents:UIControlEventTouchUpInside];
    [_btnDrinkwater addTarget:self action:@selector(tapAction:) forControlEvents:UIControlEventTouchUpInside];
    [_btnMovement addTarget:self action:@selector(tapAction:) forControlEvents:UIControlEventTouchUpInside];
    [_btnSleep addTarget:self action:@selector(tapAction:) forControlEvents:UIControlEventTouchUpInside];
    if (![self.strTag isEqualToString:@""] || self.strTag == nil || self.strTag == NULL) {
        if ([self.strTag isEqualToString:@"起床"]) {
            [_btnUp setBackgroundColor:RGB(28,154,233)];
            [_btnDrinkwater setBackgroundColor:RGB(135, 135, 135)];
            [_btnMovement setBackgroundColor:RGB(135, 135, 135)];
            [_btnSleep setBackgroundColor:RGB(135, 135, 135)];
        }else if ([self.strTag isEqualToString:@"喝水"]) {
            [_btnUp setBackgroundColor:RGB(135, 135, 135)];
            [_btnDrinkwater setBackgroundColor:RGB(28,154,233)];
            [_btnMovement setBackgroundColor:RGB(135, 135, 135)];
            [_btnSleep setBackgroundColor:RGB(135, 135, 135)];
        }else if ([self.strTag isEqualToString:@"运动"]) {
            [_btnUp setBackgroundColor:RGB(135, 135, 135)];
            [_btnDrinkwater setBackgroundColor:RGB(135, 135, 135)];
            [_btnMovement setBackgroundColor:RGB(28,154,233)];
            [_btnSleep setBackgroundColor:RGB(135, 135, 135)];
        }else if ([self.strTag isEqualToString:@"睡觉"]){
            [_btnUp setBackgroundColor:RGB(135, 135, 135)];
            [_btnDrinkwater setBackgroundColor:RGB(135, 135, 135)];
            [_btnMovement setBackgroundColor:RGB(135, 135, 135)];
            [_btnSleep setBackgroundColor:RGB(28,154,233)];
        }else{
            [_btnUp setBackgroundColor:RGB(135, 135, 135)];
            [_btnDrinkwater setBackgroundColor:RGB(135, 135, 135)];
            [_btnMovement setBackgroundColor:RGB(135, 135, 135)];
            [_btnSleep setBackgroundColor:RGB(135, 135, 135)];
        }
        _textFieldTag.text = self.strTag;
    }else{
        [_btnUp setBackgroundColor:RGB(135, 135, 135)];
        [_btnDrinkwater setBackgroundColor:RGB(135, 135, 135)];
        [_btnMovement setBackgroundColor:RGB(135, 135, 135)];
        [_btnSleep setBackgroundColor:RGB(135, 135, 135)];
    }
}

- (void)tapAction:(id)sender{//28 154 233  135
    UIButton *select = (UIButton *)sender;
    if ([select.titleLabel.text isEqualToString:@"起床"]) {
        [_btnUp setBackgroundColor:RGB(28,154,233)];
        [_btnDrinkwater setBackgroundColor:RGB(135, 135, 135)];
        [_btnMovement setBackgroundColor:RGB(135, 135, 135)];
        [_btnSleep setBackgroundColor:RGB(135, 135, 135)];
    }else if ([select.titleLabel.text isEqualToString:@"喝水"]) {
        [_btnUp setBackgroundColor:RGB(135, 135, 135)];
        [_btnDrinkwater setBackgroundColor:RGB(28,154,233)];
        [_btnMovement setBackgroundColor:RGB(135, 135, 135)];
        [_btnSleep setBackgroundColor:RGB(135, 135, 135)];
    }else if ([select.titleLabel.text isEqualToString:@"运动"]) {
        [_btnUp setBackgroundColor:RGB(135, 135, 135)];
        [_btnDrinkwater setBackgroundColor:RGB(135, 135, 135)];
        [_btnMovement setBackgroundColor:RGB(28,154,233)];
        [_btnSleep setBackgroundColor:RGB(135, 135, 135)];
    }else{
        [_btnUp setBackgroundColor:RGB(135, 135, 135)];
        [_btnDrinkwater setBackgroundColor:RGB(135, 135, 135)];
        [_btnMovement setBackgroundColor:RGB(135, 135, 135)];
        [_btnSleep setBackgroundColor:RGB(28,154,233)];
    }
    _textFieldTag.text = select.titleLabel.text;
}

- (void)sureAction{
    if (_textFieldTag.text == nil || _textFieldTag.text == NULL ||
        [_textFieldTag.text isEqualToString:@""]) {
         TIPSFORVIEW(@"未设置标签");
        return;
    }
    [self.deleaget backTagName:_textFieldTag.text];
    [self.navigationController popViewControllerAnimated:YES];

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
